﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bluyel.Core
{
    /// <summary>
    /// Represents a bool value.
    /// </summary>
    public class ValueBool : ValueBase, IValueBasic
    {
        /// <summary>
        /// The data value.
        /// </summary>
        private bool _value;

        //---------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value"></param>
        public ValueBool()
        {
            //this.DataValueType = DataValueType.Double;

            // init to empty (not to null)
            _value = false;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value"></param>
        public ValueBool(bool value)
        {
            _value = value;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Set a new value. 
        /// </summary>
        /// <param name="val"></param>
        /// <returns></returns>
        public bool SetValue(bool val)
        {
            // can be null?
            // todo:

            _value = val;
            return true;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Return the value.
        /// </summary>
        /// <returns></returns>
        public bool GetValue()
        {
            return _value;
        }

        //---------------------------------------------------------------------
        /// <summary>
        /// Compare: this == dv
        /// return true/false.
        /// </summary>
        /// <param name="dv"></param>
        /// <returns></returns>
        public override bool IsEqualsTo(IValue dv)
        {
            ValueBool dvBool = dv as ValueBool;
            if (dvBool == null)
                return false;

            return this.GetValue() == dvBool.GetValue();
        }

        //---------------------------------------------------------------------
        public override string ToString()
        {
            return "bool: " +_value.ToString();
        }
    }
}
